import { http } from '../utils/http'
import File from '@system.file'

interface  loginparams{
  username:string,
  password:string
}
export interface loginData {

  nickName:string

  avatar:string

  backgroudPicture:string

  clockinNumbers:number
  clockinTotal: number
  miniAppPicture:string
  flag:boolean

}

interface tokenData {
  data: loginData,
  message: string,
  code: number
}
interface  clockinInfo{
  year:string,
  month:string
}
interface  infoarray{
  id:string,
  createdAt:string
}
export  interface infodata{
  flag:boolean
  clockinNumbers:number
  totalClockinNumber:number
  clockins:infoarray[]

}

interface tokenData1 {
  data: infodata,
  message: string,
  code: number
}
export  interface  studylist{
  id:string

  name:string

  total:number

  done:number

  undone:number
}
export  interface studyData{
  type:string,
  list:studylist[]
}
export  interface studyinfodata{
  totalTime:number,
  studyData:studyData[]
}
interface tokenData2 {
  data: studyinfodata,
  message: string,
  code: number
}
export  interface userInfoparams{
  avatar: string,
  nickName: string
}
export interface  useravatarparams{
  file:File
}
export const clockin = (): Promise<tokenData> => {
  return http.post<tokenData>("clockin")
}
export const hasClockIn = (): Promise<tokenData> => {
  return http.get<tokenData>("hasClockIn")
}
export const clockinInfo = (data:clockinInfo): Promise<tokenData1> => {
  return http.get<tokenData1>("clockinInfo",data)
}
export const studyInfo = (): Promise<tokenData2> => {
  return http.get<tokenData2>("studyInfo",)
}
export const profile = (data:userInfoparams): Promise<tokenData> => {
  return http.post<tokenData>("userInfo/profile",data)
}
export const avatar = (data:useravatarparams): Promise<tokenData> => {
  return http.post<tokenData>("userInfo/avatar",data)
}
export interface  info{
  nickName:string

  avatar:string

  flag:boolean
  clockinNumbers:number

  clockinTotal:number

  id:string

  questionNumber:number

  totalTime:number

}
interface tokenData3 {
  data: info,
  message: string,
  code: number
}
export const userInfo = (): Promise<tokenData3> => {
  return http.post<tokenData3>("userInfo")
}
